<!DOCTYPE html>
<html lang="zh-CN">





<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="https://s2.ax1x.com/2020/01/23/1EwDcq.png">
  <link rel="icon" type="image/png" href="https://s2.ax1x.com/2020/01/23/1EwDcq.png">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="description" content="">
  <meta name="author" content="Fansure Grin">
  <meta name="keywords" content="share,hexo,blog,博客,分享">
  <title>Ubuntu中搭建Hexo博客记录（下篇） | Fansure的小栈</title>

  <link rel="stylesheet" href="/lib/font-awesome/css/all.min.css"  >
<link rel="stylesheet" href="/lib/bootstrap/css/bootstrap.min.css"  >
<link rel="stylesheet" href="/lib/mdbootstrap/css/mdb.min.css"  >
<link rel="stylesheet" href="/lib/github-markdown/github-markdown.min.css"  >

<link rel="stylesheet" href="//at.alicdn.com/t/font_1067060_qzomjdt8bmp.css">



  <link rel="stylesheet" href="/lib/prettify/tomorrow-night-eighties.min.css"  >

<link rel="stylesheet" href="/css/main.css"  >


  <link rel="stylesheet" href="/lib/fancybox/jquery.fancybox.min.css"  >


<meta name="generator" content="Hexo 4.2.0"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/">&nbsp;<strong>Fansure的小栈</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
          <li class="nav-item">
            <a class="nav-link" href="/">首页</a>
          </li>
        
          
          
          
          
          <li class="nav-item">
            <a class="nav-link" href="/archives/">归档</a>
          </li>
        
          
          
          
          
          <li class="nav-item">
            <a class="nav-link" href="/categories/">分类</a>
          </li>
        
          
          
          
          
          <li class="nav-item">
            <a class="nav-link" href="/tags/">标签</a>
          </li>
        
          
          
          
          
          <li class="nav-item">
            <a class="nav-link" href="/about/">关于</a>
          </li>
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="view intro-2" id="background"
         style="background: url('https://up.enterdesk.com/edpic_source/b2/9c/1b/b29c1b01e64b6dc14276f11a0b4190f0.jpg')no-repeat center center;
           background-size: cover;
           background-attachment: fixed;">
      <div class="full-bg-img">
        <div class="mask rgba-black-light flex-center">
          <div class="container text-center white-text fadeInUp">
            <span class="h2" id="subtitle">
              
            </span>

            
              <br>
              
                <p class="mt-3">
                  <i class="fas fa-calendar-alt" aria-hidden="true"></i>&nbsp;
                  星期二, 二月 11日 2020, 11:44 中午
                </p>
              

              <p>
                
                  
                  &nbsp;<i class="far fa-chart-bar"></i>
                  <span class="post-count">
                    562 字
                  </span>&nbsp;
                

                
                  
                  &nbsp;<i class="far fa-clock"></i>
                  <span class="post-count">
                      2 分钟
                  </span>&nbsp;
                

                
                  <!-- 不蒜子统计文章PV -->
                  
                  &nbsp;<i class="far fa-eye" aria-hidden="true"></i>&nbsp;
                  <span id="busuanzi_container_page_pv">
                    <span id="busuanzi_value_page_pv"></span> 次
                  </span>&nbsp;
                
              </p>
            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid">
  <div class="row">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-md">
      <div class="py-5 z-depth-3" id="board">
        <div class="post-content mx-auto" id="post">
          <div class="markdown-body">
            <h2 id="2-正式安装Hexo程序"><a href="#2-正式安装Hexo程序" class="headerlink" title="2.正式安装Hexo程序"></a>2.正式安装Hexo程序</h2><p>环境准备好后，安装Hexo非常简单，只要一条命令即可：<code>npm install npm-cli -g</code></p>
<p><img src="https://s2.ax1x.com/2020/02/09/1fvTK0.png" srcset="/img/loading.gif" alt="请输入图片描述"></p>
<p>具体详细介绍参考官方文档： <a href="https://hexo.io/zh-cn/docs/" target="_blank" rel="noopener">https://hexo.io/zh-cn/docs/</a> （中文的，不怕不认识洋文😌）</p>
<p>安装过程不到一分钟吧，感觉不太慢，如果安装速度不行的话，就是npm在国内网络环境中不好使，我们可以切换成淘宝 npm镜像（在淘宝的npm镜像站上还看见了nodejs的镜像，其实也可以从这上面安装最新版），使用淘宝的cnpm工具来代替npm。</p>
<p>安装cnpm：<code>npm install -g cnpm --registry=https://registry.npm.taobao.org</code></p>
<p><img src="https://s2.ax1x.com/2020/02/09/1fznfJ.png" srcset="/img/loading.gif" alt="请输入图片描述"></p>
<p>安装了这么多东西，感觉挺乱的，现在整理一下哈，我的npm在哪里呀：<code>which npm</code>一下；我的cnpm在哪里呀，<code>which cnpm</code>一下；我的node在哪里呀，<code>which node</code>一下。。。感觉自己是个强迫症 🙂</p>
<p><img src="https://s2.ax1x.com/2020/02/09/1fzRpj.png" srcset="/img/loading.gif" alt="请输入图片描述"></p>
<p>好啦，好啦，都到位啦~接下来，就是创建网站项目了。</p>
<h2 id="3-创建网站搞事情"><a href="#3-创建网站搞事情" class="headerlink" title="3.创建网站搞事情:-)"></a>3.创建网站搞事情:-)</h2><h3 id="1-我要创建个目录来存放我的网站项目，那就在我的家目录里面mkdir-一个blog文件夹吧："><a href="#1-我要创建个目录来存放我的网站项目，那就在我的家目录里面mkdir-一个blog文件夹吧：" class="headerlink" title="(1)我要创建个目录来存放我的网站项目，那就在我的家目录里面mkdir 一个blog文件夹吧："></a>(1)我要创建个目录来存放我的网站项目，那就在我的家目录里面mkdir 一个blog文件夹吧：</h3><p><img src="https://s2.ax1x.com/2020/02/09/1hCqVx.png" srcset="/img/loading.gif" alt="请输入图片描述"></p>
<h3 id="2-然后初始化我的blog目录，-执行hexo-init-你创建的项目目录或路径-命令，Hexo-将会在指定文件夹中新建所需要的文件。"><a href="#2-然后初始化我的blog目录，-执行hexo-init-你创建的项目目录或路径-命令，Hexo-将会在指定文件夹中新建所需要的文件。" class="headerlink" title="(2)然后初始化我的blog目录， 执行hexo init [你创建的项目目录或路径]命令，Hexo 将会在指定文件夹中新建所需要的文件。"></a>(2)然后初始化我的blog目录， 执行hexo init [你创建的项目目录或路径]命令，Hexo 将会在指定文件夹中新建所需要的文件。</h3><p><img src="https://s2.ax1x.com/2020/02/09/1hPTfS.png" srcset="/img/loading.gif" alt="请输入图片描述"></p>
<p>第一次克隆连接失败，哎，国内的网络环境一点都不友好…不过第二次成功了，3分钟左右吧，有点慢…</p>
<h3 id="3-切换到我的这个blog目录，先来看看有些啥玩意儿："><a href="#3-切换到我的这个blog目录，先来看看有些啥玩意儿：" class="headerlink" title="(3) 切换到我的这个blog目录，先来看看有些啥玩意儿："></a>(3) 切换到我的这个blog目录，先来看看有些啥玩意儿：</h3><p><img src="https://s2.ax1x.com/2020/02/09/1hiG7t.png" srcset="/img/loading.gif" alt="请输入图片描述"></p>
<p>要详细了解这些目录的含义，多扒拉官方文档吧 🙃 ，接下来需要在当前目录(我的是在blog下)执行 <code>cnpm install</code>，官方是 npm install，咱们要速度，就用 cnpm 来代替npm。</p>
<p><img src="https://s2.ax1x.com/2020/02/09/1hF7rj.png" srcset="/img/loading.gif" alt="请输入图片描述"></p>
<h3 id="4-执行命令-hexo-g-或者-hexo-generate-生成静态文件："><a href="#4-执行命令-hexo-g-或者-hexo-generate-生成静态文件：" class="headerlink" title="(4) 执行命令 hexo g 或者 hexo generate 生成静态文件："></a>(4) 执行命令 hexo g 或者 hexo generate 生成静态文件：</h3><p><img src="https://s2.ax1x.com/2020/02/09/1hkQeA.png" srcset="/img/loading.gif" alt="请输入图片描述"></p>
<h3 id="5-执行命令-hexo-s-或者-hexo-server-开启服务，在浏览器输入-localhost-4000-来访问本地部署的静态网站："><a href="#5-执行命令-hexo-s-或者-hexo-server-开启服务，在浏览器输入-localhost-4000-来访问本地部署的静态网站：" class="headerlink" title="(5) 执行命令 hexo s 或者 hexo server 开启服务，在浏览器输入 localhost:4000 来访问本地部署的静态网站："></a>(5) 执行命令 hexo s 或者 hexo server 开启服务，在浏览器输入 localhost:4000 来访问本地部署的静态网站：</h3><p><img src="https://s2.ax1x.com/2020/02/09/1hAttx.png" srcset="/img/loading.gif" alt="请输入图片描述"></p>
<p><img src="https://s2.ax1x.com/2020/02/09/1hADnH.png" srcset="/img/loading.gif" alt="请输入图片描述"></p>
<p>这样一个本地通过Hexo部署生成的一个静态网站就完成了，后续的工作就是修改网站的信息、写文章、换主题，把它弄得漂漂亮亮的啦~</p>

            <hr>
          </div>
          <br>
          <div>
            <p>
            
              <span>
                <i class="iconfont icon-inbox"></i>
                
                  <a class="hover-with-bg" href="/categories/%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA%20Hexo">博客搭建 Hexo</a>
                  &nbsp;
                
              </span>&nbsp;&nbsp;
            
            
              <span>
                <i class="iconfont icon-tag"></i>
                
                  <a class="hover-with-bg" href="/tags/%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA">博客搭建</a>
                
              </span>
            
            </p>
            
              <p class="note note-warning">本博客所有文章除特别声明外，均采用 <a href="https://zh.wikipedia.org/wiki/Wikipedia:CC_BY-SA_3.0%E5%8D%8F%E8%AE%AE%E6%96%87%E6%9C%AC" target="_blank" rel="nofollow noopener noopener">CC BY-SA 3.0协议</a> 。转载请注明出处！</p>
            
          </div>
        </div>
      </div>
    </div>
    <div class="d-none d-lg-block col-lg-2 toc-container">
      
  <div id="toc">
    <p class="h4"><i class="far fa-list-alt"></i>&nbsp;目录</p>
    <div id="tocbot"></div>
  </div>

    </div>
  </div>
</div>

<!-- custom -->


<!-- Comments -->
<div class="col-lg-7 mx-auto nopadding-md">
  <div class="container comments mx-auto" id="comments">
    
      <br><br>
      
      
  <div id="vcomments" style="width: 90%; margin: 0 auto;"></div>
  <script defer src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script defer src="//unpkg.com/valine/dist/Valine.min.js"></script>

  <script>
    var notify = 'false' === true;
    var verify = 'false' === true;
    var oldLoad = window.onload;
    window.onload = function () {
      new Valine({
        el: '#vcomments',
        notify: notify,
        verify: verify,
        app_id: "DySPQjS0lPUGBNigiGPGXDbU-gzGzoHsz",
        app_key: "HNYP8577C8AqC85sSrQVzwQy",
        placeholder: "快快挥霍你的口水吧~",
        avatar: "retro",
        meta: ['nick', 'mail', 'link'],
        pageSize: "10",
      });
      oldLoad && oldLoad();
    };
  </script>
  <noscript>Please enable JavaScript to view the <a href="https://valine.js.org" target="_blank" rel="nofollow noopener noopener">comments
      powered by Valine.</a></noscript>


    
  </div>
</div>

    
  </main>

  
    <a class="z-depth-1" id="scroll-top-button" href="#" role="button">
      <i class="fa fa-chevron-up scroll-top-arrow" aria-hidden="true"></i>
    </a>
  

  
    <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
  

  <footer class="mt-5">
  <div class="text-center py-3">
    <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><b>Hexo</b></a>
    <i class="iconfont icon-love"></i>
    <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"> <b>Fluid</b></a>
    <br>

    
  
    <!-- 不蒜子统计PV -->
    
    &nbsp;<span id="busuanzi_container_site_pv">总访问量 
          <span id="busuanzi_value_site_pv"></span> 次</span>&nbsp;
  
  
    <!-- 不蒜子统计UV -->
    
    &nbsp;<span id="busuanzi_container_site_uv">总访客数 
            <span id="busuanzi_value_site_uv"></span> 人</span>&nbsp;
  
  <br>



    


    <!-- cnzz Analytics icon -->
    

  </div>
</footer>

<!-- SCRIPTS -->
<script src="/lib/jquery/jquery.min.js" ></script>
<script src="/lib/popper/popper.min.js" ></script>
<script src="/lib/bootstrap/js/bootstrap.min.js" ></script>
<script src="/lib/mdbootstrap/js/mdb.min.js" ></script>
<script src="/js/main.js" ></script>


  <script src="/js/lazyload.js" ></script>



  
    <script src="/lib/tocbot/tocbot.min.js" ></script>
  
  <script src="/js/post.js" ></script>



  <script src="/lib/smooth-scroll/smooth-scroll.min.js" ></script>



  <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>


<!-- Plugins -->


  

  

  

  

  <!-- cnzz Analytics -->
  



  <script src="/lib/prettify/prettify.min.js" ></script>
  <script>
    $(document).ready(function () {
      $('pre').addClass('prettyprint  linenums');
      prettyPrint();
    })
  </script>



  <script src="/lib/typed/typed.min.js" ></script>
  <script>
    var typed = new Typed('#subtitle', {
      strings: [
        '  ',
        "Ubuntu中搭建Hexo博客记录（下篇）&nbsp;",
      ],
      cursorChar: "_",
      typeSpeed: 70,
      loop: false,
    });
    typed.stop();
    $(document).ready(function () {
      $(".typed-cursor").addClass("h2");
      typed.start();
    });
  </script>



  <script src="/lib/anchor/anchor.min.js" ></script>
  <script>
    anchors.options = {
      placement: "right",
      visible: "false",
      
    };
    var el = "h1,h2,h3,h4,h5,h6".split(",");
    var res = [];
    for (item of el) {
      res.push(".markdown-body > " + item)
    }
    anchors.add(res.join(", "))
  </script>



  <script src="/js/local-search.js" ></script>
  <script>
    var path = "/local-search.xml";
    var inputArea = document.querySelector("#local-search-input");
    inputArea.onclick = function () {
      getSearchFile(path);
      this.onclick = null
    }
  </script>



  <script src="/lib/fancybox/jquery.fancybox.min.js" ></script>
  <script>
    $("#post img:not(.no-zoom img, img[no-zoom])").each(
      function () {
        var element = document.createElement("a");
        $(element).attr("data-fancybox", "images");
        $(element).attr("href", $(this).attr("src"));
        $(this).wrap(element);
      }
    );
  </script>





  
  
    <script>
      !function (e, t, a) {
        function r() {
          for (var e = 0; e < s.length; e++) s[e].alpha <= 0 ? (t.body.removeChild(s[e].el), s.splice(e, 1)) : (s[e].y--, s[e].scale += .004, s[e].alpha -= .013, s[e].el.style.cssText = "left:" + s[e].x + "px;top:" + s[e].y + "px;opacity:" + s[e].alpha + ";transform:scale(" + s[e].scale + "," + s[e].scale + ") rotate(45deg);background:" + s[e].color + ";z-index:99999");
          requestAnimationFrame(r)
        }

        function n() {
          var t = "function" == typeof e.onclick && e.onclick;
          e.onclick = function (e) {
            t && t(), o(e)
          }
        }

        function o(e) {
          var a = t.createElement("div");
          a.className = "heart", s.push({
            el: a,
            x: e.clientX - 5,
            y: e.clientY - 5,
            scale: 1,
            alpha: 1,
            color: c()
          }), t.body.appendChild(a)
        }

        function i(e) {
          var a = t.createElement("style");
          a.type = "text/css";
          try {
            a.appendChild(t.createTextNode(e))
          } catch (t) {
            a.styleSheet.cssText = e
          }
          t.getElementsByTagName("head")[0].appendChild(a)
        }

        function c() {
          return "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + ")"
        }

        var s = [];
        e.requestAnimationFrame = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e.mozRequestAnimationFrame || e.oRequestAnimationFrame || e.msRequestAnimationFrame || function (e) {
          setTimeout(e, 1e3 / 60)
        }, i(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"), n(), r()
      }(window, document);
    </script>
  







</body>
</html>
